Caffe 其實蠻好編譯的,只是有幾個地方要注意一下,那廢話不多說,就讓我們開始吧
sudo apt install libboost1.58-all-dev libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libatlas-base-dev libgflags-dev libgoogle-glog-dev liblmdb-dev python-pip python-scipy python3-scipy -y
git clone https://github.com/BVLC/caffe.git
下載前要先註冊會員,這邊沒什麼我就不仔細講解了。
解壓縮並安裝 MKL
tar xvfz l_mkl_2018.1.163.tgz
cd l_mkl_2018.1.163
sudo ./install_GUI.sh
增加 MKL 的環境變數到 .bashrc ,並用 source ~/.bashrc 來更新環境變數
source /opt/intel/mkl/bin/mklvars.sh intel64
cd caffe
cp Makefile.config.example ./Makefile.config
vim Makefile.config
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
7.取消註解 WITH_PYTHON_LAYER
cd /usr/lib/x86_64-linux-gnu/
sudo ln -s libhdf5_serial.so.10.1.0 ./libhdf5.so
sudo ln -s libhdf5_serial_h1.so.10.1.0 ./libhdf5_h1.so
cd caffe
cd python
pip install -U --user setuptools
for req in $(cat requirements.txt); do pip install $req -U --user; done
make all -j8
make test -j8
make pycaffe -j8
export PYTHONPATH=$PYTHONPATH:~/caffe/python